// import { Result } from './port';
import service from "@/utils/https";

//端口转发列表分页查询
export interface SearchPortParams {
    pageSize: number;
    pageNum: number;
    remark?: string;
    sn?: string;
    srcPort?: number;
    groupId?: number;
}

export const SelectPortListApi = (params: SearchPortParams) => {
    return service({
        method: "GET",
        url: "/forward",
        params,
    });
};

//端口转发记录添加
export interface ForwardAddParams {
    id?: number;
    sn?: string;
    srcPort?: number;
    tarPort?: number;
    remark?: string;
    status?: boolean;
    outProtocol?: number
    groupId?: number;
}

export const AddForwardApi = (data: ForwardAddParams) => {
    return service({
        method: "POST",
        url: "/forward",
        data,
    });
};

// 端口转发添加模板下载
export const DownloadAddTempServerToServerApi = () => {
    return service({
        method: "GET",
        url: `/download/templateServerToServer`,
        responseType: "blob",
    });
};
// 批量添加数据
export const BatchAddDataForwardServerToServerApi = (data: any) => {
    return service({
        method: "POST",
        url: "/forward/batchAdd",
        data,
        headers: {
            "Content-Type": "multipart/form-data",
        },
    });
};


//端口转发记录修改（备注或者开启或关闭转发）

export const UpdateForwardApi = (data: ForwardAddParams) => {
    return service({
        method: "PUT",
        url: "/forward",
        data,
    });
};

//删除端口转发记录
export const DeleteForwardApi = (id: number) => {
    return service({
        method: "DELETE",
        url: `/forward/${id}`,
    });
};

// 开启或者关闭转发服务

export interface StartCloseParams {
    srcPort: number;
    tarPort: number;
    flag: boolean;
}

export const StartCloseForwardApi = (params: StartCloseParams) => {
    return service({
        method: "GET",
        url: `/forward/start`,
        params,
    });
};


//智翔解算转发记录添加*************************************************************************************************

// 智想解算批量添加模板下载
export const DownloadAddTempApi = () => {
    return service({
        method: "GET",
        url: `/download/excel`,
        responseType: "blob",
    });
};

//智翔解算转发列表分页查询
export interface SearchDataForwardParams {
    pageSize: number;
    pageNum: number;
    sn?: string;
    remark?: string;
    srcPort?: number;
}

export const SelectDataForwardListApi = (params: SearchDataForwardParams) => {
    return service({
        method: "GET",
        url: "/dataForward",
        params,
    });
};

export interface DataForwardAddParams {
    srcPort?: number;
    remark?: string;
    sn: string;
    stationId?: number;
    tranTcpUrl?: string;
    parseServerUrlId?: number;
}

// 修改转发记录
export const UpdateDataForwardApi = (data: DataForwardAddParams) => {
    return service({
        method: "PUT",
        url: "/dataForward",
        data,
    });
}

export const AddDataForwardApi = (data: DataForwardAddParams) => {
    return service({
        method: "POST",
        url: "/dataForward",
        data,
    });
};

//删除智翔解算对接端口转发记录
export const DeleteDataForwardApi = (id: number) => {
    return service({
        method: "DELETE",
        url: `/dataForward/${id}`,
    });
};

// 开启或者关闭智翔解算对接转发服务

export interface StartCloseDataParams {
    srcPort: number;
    flag: boolean;
}

export const StartCloseDataForwardApi = (params: StartCloseDataParams) => {
    return service({
        method: "GET",
        url: `/dataForward/start`,
        params,
    });
};

// 批量添加数据
export const BatchAddDataForwardApi = (data: any) => {
    return service({
        method: "POST",
        url: "/dataForward/batchAdd",
        data,
        headers: {
            "Content-Type": "multipart/form-data",
        },
    });
};


// ntrip站点添加****************************************************************************************************************

export interface NtripStationAddParams {
    id?: number;
    remark?: string;
    stationName: string;
    mountPoint: string;
    isUnAuth: boolean;
    groupId: number;
    way: number
}

export const AddNtripStationApi = (data: NtripStationAddParams) => {
    return service({
        method: "POST",
        url: "/ntripStation",
        data,
    });
};
// ntrip站点删除
export const DeleteNtripStationApi = (id: number) => {
    return service({
        method: "DELETE",
        url: `/ntripStation/${id}`,
    });
};

// ntrip站点查询
export interface SearchNtripStationParams {
    pageSize: number;
    pageNum: number;
    stationName?: string;
    remark?: string;
    mountPoint?: string;
    groupId?: number;
}

export const GetNtripStationApi = (params: SearchNtripStationParams) => {
    return service({
        method: "GET",
        url: "/ntripStation",
        params,
    });
};
// ntrip站点修改
export const EditNtripStationApi = (data: NtripStationAddParams) => {
    return service({
        method: "PUT",
        url: "/ntripStation",
        data,
    });
};

// 开启或者关闭ntrip基站服务

export interface StartCloseNtripStationParams {
    mountPoint: string;
    flag: boolean;
}

export const StartCloseNtripStationApi = (
    params: StartCloseNtripStationParams
) => {
    return service({
        method: "GET",
        url: `/ntripStation/start`,
        params,
    });
};

// 开启或者关闭ntripServer服务

export const StartCloseNtripServerApi = (port: number, flag: boolean) => {
    return service({
        method: "GET",
        url: `/ntrip/start`,
        params: {flag, port},
    });
};

//查看ntrip服务运行状态
export const GetNtripStatusinfoServerApi = () => {
    return service({
        method: "GET",
        url: `/ntrip/status`,
    });
};
//修改ntrip服务运行端口
export const EditNtripStatusinfoServerApi = (port: string) => {
    return service({
        method: "PUT",
        url: `/ntrip/status`,
        params: {port},
    });
};
//获取基站在线用户

export const GetNtripOnlineUserApi = (mountPoint: string) => {
    return service({
        method: "GET",
        url: `/ntrip/onlineuser`,
        params: {mountPoint},
    });
};

//获取所有站点简洁信息
export const GetNtripStationAllApi = () => {
    return service({
        method: "GET",
        url: `/ntripAuthStation`,
    });
};

// ntrip认证添加***************************************************************************************************************

export interface NtripAuthAddParams {
    id?: number;
    username: string;
    password: string;
    remark?: string;
    mountPoint: number | undefined;
}

export const AddNtripAuthApi = (data: NtripAuthAddParams) => {
    return service({
        method: "POST",
        url: "/ntripAuth",
        data,
    });
};
// ntrip认证删除
export const DeleteNtripAuthApi = (id: Number) => {
    return service({
        method: "DELETE",
        url: `/ntripAuth/${id}`,
    });
};

// ntrip认证查询
export interface SearchNtripAuthParams {
    pageSize: number;
    pageNum: number;
    username?: string;
    remark?: string;
}

export const GetNtripAuthApi = (params: SearchNtripAuthParams) => {
    return service({
        method: "GET",
        url: "/ntripAuth",
        params,
    });
};
// ntrip认证修改
export const EditNtripAuthApi = (data: NtripAuthAddParams) => {
    return service({
        method: "PUT",
        url: "/ntripAuth",
        data,
    });
};

// 登录接口

export const LoginAuthApi = (username: string, password: string) => {
    return service({
        method: "POST",
        url: "/login",
        data: {
            username,
            password,
        },
    });
};

// 返回结果
export interface Result<T> {
    code: number;
    msg: string;
    data: T;
}

// 列表数据
export interface ResultList<T> {
    total: number;
    list: T | null;
}
